package com.guigu.xm.wp.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.xm.pojo.DFile;
import com.guigu.xm.pojo.PageVo;
import com.guigu.xm.pojo.SGatherDetails;
import com.guigu.xm.pojo.SPayDetails;
import com.guigu.xm.wp.mapper.DFileMapper;
import com.guigu.xm.wp.mapper.SGatherDetailsMapper;
import com.guigu.xm.wp.mapper.SPayDetailsMapper;
import com.guigu.xm.wp.service.HtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Service
public class HTServlet implements HtService {
    @Autowired(required = false)
    DFileMapper dFileMapper;
    @Autowired(required = false)
    SGatherDetailsMapper detailsMapper;
    @Autowired(required = false)
    SPayDetailsMapper sPayDetailsMapper;
    @Override
    public int selID() {
        String s = dFileMapper.selId();
        return Integer.parseInt(s);
    }

    @Override
    public PageVo<DFile> selUp(int page, int num,DFile dFile) {
        PageHelper.startPage(page,num);
        List<DFile> dFiles = dFileMapper.selUp(dFile);
        PageInfo info=new PageInfo(dFiles);
        PageVo pageVo=new PageVo<DFile>();
        pageVo.setRows(dFiles);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    public PageVo<DFile> selRk(int page, int num, DFile dFile){
        PageHelper.startPage(page,num);
        List<DFile> postcode = dFileMapper.selRk(dFile);
        PageInfo info=new PageInfo(postcode);
        PageVo pageVo=new PageVo<DFile>();
        pageVo.setRows(postcode);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int update(DFile dFile) {
        return dFileMapper.upRk(dFile);
    }

    public PageVo<DFile> query(int page, int num, DFile dFile){
        PageHelper.startPage(page,num);
        List<DFile> postcode = dFileMapper.query(dFile);
        PageInfo info=new PageInfo(postcode);
        PageVo pageVo=new PageVo<DFile>();
        pageVo.setRows(postcode);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int addSGatherDetails(SGatherDetails sGatherDetails) {
        return detailsMapper.insert(sGatherDetails);
    }

    @Override
    public PageVo<SGatherDetails> queryID(int page, int num, SGatherDetails sGatherDetails) {
        PageHelper.startPage(page,num);
        List<SGatherDetails> postcode = detailsMapper.queryId(sGatherDetails);
        PageInfo info=new PageInfo(postcode);
        PageVo pageVo=new PageVo<SGatherDetails>();
        pageVo.setRows(postcode);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int updateId(SGatherDetails sGatherDetails) {
        return detailsMapper.updateId(sGatherDetails);
    }

    @Override
    public int selectPid(SGatherDetails sGatherDetails) {

        return detailsMapper.selectPid(sGatherDetails);
    }

    @Override
    public PageVo<SGatherDetails> queryAll(int page, int num) {
        PageHelper.startPage(page,num);
        List<SGatherDetails> postcode = detailsMapper.queryAll();
        PageInfo info=new PageInfo(postcode);
        PageVo pageVo=new PageVo<SGatherDetails>();
        pageVo.setRows(postcode);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int addSP(SPayDetails sGatherDetails) {
        return sPayDetailsMapper.insert(sGatherDetails);
    }

    @Override
    public PageVo<SPayDetails> queryCks(int page, int num, SPayDetails sGatherDetails) {
        PageHelper.startPage(page,num);
        List<SPayDetails> postcode = sPayDetailsMapper.queryCks(sGatherDetails);
        PageInfo info=new PageInfo(postcode);
        PageVo pageVo=new PageVo<SPayDetails>();
        pageVo.setRows(postcode);
        pageVo.setTotal(info.getTotal());
        return pageVo;
    }

    @Override
    public int updateCks(SPayDetails sGatherDetails) {
        return sPayDetailsMapper.updateCks(sGatherDetails);
    }

    @Override
    public int selectCKPid(SPayDetails sGatherDetails) {
        return sPayDetailsMapper.selectCkPid(sGatherDetails);
    }

}
